package com.mxw.account.enums;

import lombok.AllArgsConstructor;

/** 发票状态：0初始草稿 1待审核 2通过 10拒绝 */
@AllArgsConstructor
public enum InvoiceStatusEnum implements PersistableEnum<Integer> {
  INIT(0),

  PENDING(1),

  APPROVED(2),

  ACCEPTED(3),

  REJECTED(4),

  PAID(5), // lerder打款给Supplier

  RECEIVED(6), // 在backoffice端，确认lerder打款给Supplier
  ARRIVED(16), // Supplier确认收到款

  OPEN(7),

  REPAID(8), // Supplier还款给lender
  UNREPAID(15), // 到期未还款

  ISSUING(9),
  REFUSED(10), // lender拒绝

  REVIEWED(11), // backoffice评估invoice通过
  FAILED(14), // backoffice评估invoice不通过

  COMPLETED(12), // backoffice，Supplier确认还款给lender，流程结束
  ISSUED(13),

  ACCEPTING_REVIEWED(37), // 与DBEntityStatusEnum状态值统一,同意
  REVIEW_FAILED(38), // 与DBEntityStatusEnum状态值统一，拒绝

  REPAYMENT_REVIEWED(50),
  REPAYMENT_REVIEW_FAILED(51),
  REPAYMENT_VERIFYING_FAILED(52),

  EXPIRE(20), // 过期

  CANCELED(25); // CERC取消保理申请。

  private Integer value;

  public static InvoiceStatusEnum get(Integer value) {
    if (value != null) {
      for (InvoiceStatusEnum temp : InvoiceStatusEnum.values()) {
        if (temp.getValue().equals(value)) {
          return temp;
        }
      }
    }
    return null;
  }

  @Override
  public Integer getValue() {
    return this.value;
  }

  public static class Converter extends AbstractEnumConverter<InvoiceStatusEnum, Integer> {
    public Converter() {
      super(InvoiceStatusEnum.class);
    }
  }
}
